
struct ListNode* reverseList(struct ListNode* head){

    if(head == NULL)
    {
        return NULL;
    }
    struct ListNode* prev = NULL,*cur = head->next;

    while(head)
    {
        head->next = prev;
        prev = head;
        head = cur;
        if(cur)
            cur = cur->next;
    } 
    head = prev;
    return head;
}